package com.qidian.buy.cms.controller;

import com.qidian.buy.cms.service.IContentCategoryService;
import com.qidian.buy.common.pojo.BuyResult;
import com.qidian.buy.pojo.ContentCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 戴着假发的程序员
 * @company 起点编程
 * @date 2024/7/12 10:26
 */
@CrossOrigin
@RequestMapping("/contentCategory")
@RestController
public class ContentCategoryController {
    @Autowired
    private IContentCategoryService categoryService;

    @GetMapping("/queryAll")
    public BuyResult queryAll(){
        return categoryService.queryAll();
    }
    @PostMapping("/save")
    public BuyResult save(@RequestBody ContentCategory category){
        return categoryService.saveCat(category);
    };
    @GetMapping("/queryByParentId")
    public BuyResult queryByParentId( @RequestParam(defaultValue = "1")int page,@RequestParam(defaultValue = "10") int limit,Long parentId){
        return categoryService.queryByParentId(parentId,page,limit);
    }
    @GetMapping("/get/{catId}")
    public BuyResult get(@PathVariable Long catId){
        return categoryService.get(catId);
    }
}
